package com.gshocklab.bulkposter.data.dto;

import java.text.DateFormat;
import java.util.Date;

import android.content.ContentValues;

import com.gshocklab.bulkposter.data.DatabaseAdapter;
import com.gshocklab.bulkposter.data.IPersistent;

/**
 * Recently posted message DTO
 * @author vitaly gashock
 */

public final class PostedMessage implements IPersistent {
	public int id;
	public String postText;
	public SocialAccount account;
	public Date postingDate;
	
	public PostedMessage() {
	}
	
	@Override
	public ContentValues prepareForPersistance() {
		final ContentValues values = new ContentValues();
		
		values.put(DatabaseAdapter.POST_TEXT_COLUMN, postText);
		values.put(DatabaseAdapter.ACCOUNT_ID_COLUMN, account.id);
		
		DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG);
		
		values.put(DatabaseAdapter.POST_DATE_COLUMN, dateFormatter.format(postingDate).toString());
		
		return values;
	}
}
